///**
// * Created by malingling on 15-12-17.
// */
app.controller('DetailCtrl',function($scope,$location){
    $.ajaxSettings.async = false;
    $.getJSON('../json/data.json',function(data){
        $scope.people = data['people']
    })

    $scope.back_to_up_page = function(){
        $location.path('')
    }

       var order_inform = JSON.parse(localStorage.getItem('all_inform'))||[];

        $scope.informs = order_inform;
        $scope.count = ($scope.informs).length;
        $scope.sum = sum($scope.informs).toFixed(2);
    var order_people = order_person_informs(order_inform);
     $scope.people = none_order_people(order_people,$scope.people)

    $scope.people = none_order_people(order_person_informs(order_inform),$scope.people)
    $scope.none_count = ($scope.people).length

})
function order_person_informs(informs){
    var order_person_informs = {};
    informs.forEach(function(inform){
        order_person_informs[inform.person] = inform.person;
    })
    return order_person_informs;
}

function none_order_people(names,informs){
    var none_order_people = [];
    informs.forEach(function(inform){
      if(names[inform] != inform){
          none_order_people.push(inform)
          console.log(inform)
      }
    })
    return none_order_people
}
function sum (informs){
    var sum = 0;
    informs.forEach(function(inform){
        sum += parseFloat(inform.price)
    })
    return sum;
}
